import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import Confirm from 'vux/src/components/confirm/index.vue';
import util from '@/common/util.js';

export default {
  name: 'qj_list',
  components: {Confirm},
  data () {
    return {
      siteId: '',
      // 班级id
      id: '',
      studentId: '',
      studentName: '',
      content: {},
      isDisabled:false,
      signClass:'signUpBtn',
      agree: true,
      show: false
    }
  },
  mounted () {
    this.$router.afterEach((to, from, next) => {
      window.scrollTo(0, 0);
    });
    var _this = this
    var studertids = ''
    _this.siteId = window.sessionStorage.getItem('siteId')
    _this.studentId = window.sessionStorage.getItem('studentId')
    _this.id = window.sessionStorage.getItem('event_id')
    studertids = _this.studentId
    if (studertids == '-1') {
      studertids = ''
    }
   _this.loadList()
  },
  methods: {
    loadList() {
      var _this = this
      http.post(CONSTANT.LEAVELIST, {
        userId: _this.studentId,
        orgId: _this.siteId,
        pageNo: 1
      }, (res) => {
        console.log(res)
        _this.content = res.content
      for (var i = 0;i < _this.content.length;i++) {
        //let dateStr = util.dateFormat(_this.content[i].createdDate,true)
        //_this.content[i].createdDate = dateStr.substring(0,10)
        if (_this.content[i].status == '2') {
          _this.content[i].status = '审核中'
        } else if (_this.content[i].status == '1') {
          _this.content[i].status = '通过'
        } else if (_this.content[i].status == '0') {
          _this.content[i].status = '被退回'
        }
      }
    })
    },
    comeBack () {
      this.$router.push({path: '/mine'})
    },
    deleteQj(id) {
      /*if(confirm("确定要删除吗？")){
        http.post(CONSTANT.LEAVEDELETE, {
          id: id
        }, (res) => {
            alert(res)
            this.loadList()
        })
      }else {

      }*/
      this.$router.push({path: '/qj_detail',query:{id: id}})
    },
    goQj () {
      this.$router.push({path: '/qj'})
    }
  }
}
